package org.lex.elec.apps.cad.model.device;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.lex.elec.apps.cad.model.Load;
import org.lex.elec.model.datatype.HasId;
import org.lex.elec.model.datatype.HasName;

public class Circuit implements HasId<String>, HasName {
	
	private String id = null;
	private String name = null;
	private List<Device> devices = new ArrayList<>(2);
	private List<Feeder> feeders = new ArrayList<>(1);
	private Load load = null;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		Objects.requireNonNull(id, "circuit id can't be null");
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Device> getDevices() {
		return devices;
	}

	public void addDevice(Device d) {
		this.devices.add(d);
	}

	public void setDevices(List<Device> devices) {
		Objects.requireNonNull(devices, "devices can't be null");
		this.devices = devices;
	}

	public List<Feeder> getFeeders() {
		return feeders;
	}
	
	public void setFeeder(Feeder feeder){
		Objects.requireNonNull(feeder, "Feeders can't be null");
		this.feeders.clear();
		this.feeders.add(feeder);
	}

	public void setFeeders(List<Feeder> feeders) {
		Objects.requireNonNull(feeders, "Feeders can't be null");
		this.feeders = feeders;
	}

	public Load getLoad() {
		return load;
	}

	public void setLoad(Load load) {
		this.load = load;
	}
}
